import React from 'react';
import {Route, Redirect} from 'react-router-dom';
import { useLgContext } from '../components/userContext';

const AuthRoute = (props) => {
    const {state,dispatch} = useLgContext();
    // 如果没有用户名说明没登录，跳转到登录页面
    if(!state.username){
        return <Redirect to='/login' />
    }
    return <Route {...props}/>
}

export default AuthRoute